//该题并非是判断是否存在有向无环图，只是判断入度为0的结点是不是唯一即可，不需要队列和图存储
#include <iostream>
#include <map>

using namespace std;
map<string, int> map_data;

int main(int argc, char const* argv[])
{
    int n;
    int degree[1001];
    while (cin >> n) {
        if (n == 0)
            break;

        //init
        map_data.clear();
        for (int i = 0; i < 1001; i++) {
            degree[i] = 0;
        }

        int name_index = 0;
        for (int i = 0; i < n; i++) {
            string name1, name2;
            cin >> name1 >> name2;
            if (map_data.find(name1) == map_data.end())
                map_data[name1] = name_index++;
            if (map_data.find(name2) == map_data.end())
                map_data[name2] = name_index++;
            degree[map_data[name2]]++;
        }

        int count = 0;
        for (int i = 0; i < name_index; i++) {
            if (degree[i] == 0)
                count++;
        }
        if (count == 1)
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }
    return 0;
}